<template>
  <!-- <div
      v-for="(item, idx) in form.value"
      :key="idx"></div> -->

  <div style="background-color: #eff1f2; padding: 12px">
    <div
      style="
        flex: 1;
        margin-right: 12px;
        background-color: white;
        padding: 12px;
        border-radius: 8px;
      "
      v-if="form.wokerRemarkTypes"
    >
      <div>
        <div style="display: flex">
          <div
            style="
              height: 20px;
              width: 4px;
              margin-right: 12px;
              background: linear-gradient(#2456e0, #24ade0);
              border-radius: 4px;
            "
          ></div>
          <div style="font-size: 18px; font-weight: bold">师傅评价类型</div>
        </div>

        <!-- 默认评价：-->
        <div
          style="margin-top: 20px"
          v-for="(item, idx) in form.wokerRemarkTypes"
          :key="idx"
        >
          <div style="margin-bottom: 10px;">默认{{ item.type }}：</div>
          <div style="display: flex; flex-wrap: wrap">
            <el-tag
              :key="tag"
              v-for="tag in item.list"
              closable
              :disable-transitions="false"
              @close="workHandleClose(tag, 'work')"
            >
              {{ tag }}
            </el-tag>

            <el-input
              class="input-new-tag"
              v-if="item.workInputVisible"
              v-model="item.inputValue"
              ref="saveTagInput"
              size="small"
              @keyup.enter.native="workHandleInputConfirm"
              @blur="workHandleInputConfirm(item.type, 'work')"
            >
            </el-input>
            <el-button
              v-else
              class="button-new-tag"
              size="small"
              @click="workShowInput(item.type, 'work')"
              >+</el-button>
          </div>
        </div>
      </div>
    </div>

    <div
      style="
        flex: 1;
        margin-right: 12px;
        background-color: white;
        padding: 12px;
        border-radius: 8px;
        margin-top: 12px;
      "
      v-if="form.userRemarkTypes"
    >
      <div>
        <div style="display: flex">
          <div
            style="
              height: 20px;
              width: 4px;
              margin-right: 12px;
              background: linear-gradient(#2456e0, #24ade0);
              border-radius: 4px;
            "
          ></div>
          <div style="font-size: 18px; font-weight: bold">用户评价类型</div>
        </div>
        <!-- 默认评价：-->
        <div
          style="margin-top: 20px"
          v-for="(item, idx) in form.userRemarkTypes"
          :key="idx"
        >
          <div style="margin-bottom: 10px;">默认{{ item.type }}：</div>
          <div style="display: flex; flex-wrap: wrap">
            <div style="display: flex; flex-wrap: wrap">
              <el-tag
                :key="tag"
                v-for="tag in item.list"
                closable
                :disable-transitions="false"
                @close="workHandleClose(tag, 'user')"
              >
                {{ tag }}
              </el-tag>

              <el-input
                class="input-new-tag"
                v-if="item.workInputVisible"
                v-model="item.inputValue"
                ref="saveTagInput"
                size="small"
                @keyup.enter.native="workHandleInputConfirm"
                @blur="workHandleInputConfirm(item.type, 'user')"
              >
              </el-input>
              <el-button
                v-else
                class="button-new-tag"
                size="small"
                @click="workShowInput(item.type, 'user')"
                >+</el-button
              >
            </div>
          </div>
        </div>
      </div>
    </div>

    <div
      style="
        flex: 1;
        margin-right: 12px;
        background-color: white;
        padding: 12px;
        border-radius: 8px;
        margin-top: 12px;
      "
      v-if="form.timeLimitTypes"
    >
      <div style="display: flex">
        <div
          style="
            height: 20px;
            width: 4px;
            margin-right: 12px;
            background: linear-gradient(#2456e0, #24ade0);
            border-radius: 4px;
          "
        ></div>
        <div style="font-size: 18px; font-weight: bold">时间约定方式</div>
      </div>
      <!-- table -->
      <div style="margin-top: 20px">
        <el-table :data="form.timeLimitTypes" style="width: 100%">
          <el-table-column label="时间约定方式" width="180">
            <template slot-scope="scope">
              <el-input type="input" v-model="scope.row.name" ></el-input>
            </template>
          </el-table-column>

          <el-table-column label="日期" width="180">
              <template slot-scope="scope">
                <el-checkbox v-model="scope.row.checkedList[0]">必填</el-checkbox>
              </template>
            </el-table-column>

            <el-table-column label="启始时点" width="180">
              <template slot-scope="scope">
                <el-checkbox v-model="scope.row.checkedList[1]">必填</el-checkbox>
              </template>
            </el-table-column>

            <el-table-column label="截止时点" width="180">
              <template slot-scope="scope">
                <el-checkbox v-model="scope.row.checkedList[2]">必填</el-checkbox>
              </template>
            </el-table-column>

          <el-table-column label="说明">
            <template slot-scope="scope">
              <el-input
                type="textarea"
                :rows="2"
                v-model="scope.row.note"
              ></el-input>
            </template>
          </el-table-column>
        </el-table>

        <div style="padding: 20px; padding-left: 0; display: flex">
          <el-button style="width: 88px" @click="onAddTimeRow">
            <i class="el-icon-plus"></i>
          </el-button>
        </div>
      </div>
    </div>



    <div v-if="form.roleTypes">
        <div
          style="
            flex: 1;
            margin-right: 12px;
            background-color: white;
            padding: 12px;
            border-radius: 8px;
            margin-top: 12px;
          "
        >
          <div style="display: flex; align-items: center">
            <div
              style="
                height: 20px;
                width: 4px;
                margin-right: 12px;
                background: linear-gradient(#2456e0, #24ade0);
                border-radius: 4px;
              "
            ></div>
            <div style="font-size: 18px; font-weight: bold">身份约定</div>
            <div style="font-size: 12px; color: #999999; margin-left: 12px">
              接单人需如实选择以下身份类型，若选择类型错误，可能出现被投诉，被索赔等情形。
            </div>
          </div>
          <!-- table -->
          <div style="margin-top: 12px">
            <el-table :data="form.roleTypes" style="width: 100%">
              <el-table-column label="" width="50" type="index"></el-table-column>

              <el-table-column label="名称" width="180">
                <template slot-scope="scope">
                  <el-input v-model="scope.row.name"></el-input>
                </template>
              </el-table-column>

              <el-table-column label="说明">
                <template slot-scope="scope">
                  <el-input v-model="scope.row.note"></el-input>
                </template>
              </el-table-column>

              <el-table-column label="类别">
                <template slot-scope="scope">
                  <el-select
                    v-model="scope.row.extendList"
                    multiple
                    placeholder="请选择"
                  >
                    <el-option
                      v-for="(itemType, index) in types"
                      :key="index"
                      :label="itemType.name"
                      :value="itemType.name"
                    >
                    </el-option>
                  </el-select>
                </template>
              </el-table-column>
            </el-table>

            <div style="padding: 20px; padding-left: 0; display: flex">
              <el-button style="width: 88px" @click="onAddRoleRow">
                <i class="el-icon-plus"></i>
              </el-button>
            </div>
          </div>
        </div>
    </div>

  <div v-if="form.skillTypes">
        <div
          style="
            flex: 1;
            margin-right: 12px;
            background-color: white;
            padding: 12px;
            border-radius: 8px;
            margin-top: 12px;
          "
        >
          <div style="display: flex; align-items: center">
            <div
              style="
                height: 20px;
                width: 4px;
                margin-right: 12px;
                background: linear-gradient(#2456e0, #24ade0);
                border-radius: 4px;
              "
            ></div>
            <div style="font-size: 18px; font-weight: bold">我的技能</div>
          </div>
          <!-- table -->
          <div>
            <el-table :data="form.skillTypes" style="width: 100%">
              <el-table-column label="" width="180">
                <template slot-scope="scope">
                  <el-input v-model="scope.row.name" style="flex: 1"></el-input>
                </template>
              </el-table-column>

              <el-table-column label="" width="330">
                <template slot-scope="scope">
                  <div style="display: flex">
                    <div style="margin-right: 12px">资质证书名称</div>
                    <el-input
                      v-model="scope.row.skillStr"
                      style="flex: 1"
                    ></el-input>
                  </div>
                </template>
              </el-table-column>

              <el-table-column label="">
                <template slot-scope="scope">
                  <div style="display: flex">
                    <div style="margin-right: 12px">技能说明</div>
                    <el-input
                      v-model="scope.row.note"
                      style="flex: 1"
                    ></el-input>
                  </div>
                </template>
              </el-table-column>
            </el-table>

            <div style="padding: 20px; padding-left: 0; display: flex">
              <el-button style="width: 88px" @click="onAddSkillTypesRow">
                <i class="el-icon-plus"></i>
              </el-button>
            </div>
          </div>
        </div>
      </div>


      <div v-if="form.approveTypes">
        <div
          style="
            flex: 1;
            margin-right: 12px;
            background-color: white;
            padding: 12px;
            border-radius: 8px;
            margin-top: 12px;
          "
        >
          <div style="display: flex; align-items: center">
            <div
              style="
                height: 20px;
                width: 4px;
                margin-right: 12px;
                background: linear-gradient(#2456e0, #24ade0);
                border-radius: 4px;
              "
            ></div>
            <div style="font-size: 18px; font-weight: bold">提现审批</div>
          </div>
          <div style="display: flex; margin-top: 12px">
            <div style="display: flex; align-items: center; flex: 1">
              <div style="margin-right: 12px">每次提现无审核上限</div>
              <el-input v-model="form.approveTypes[0].name" style="width: 200px"></el-input>
            </div>

            <div style="display: flex; align-items: center; flex: 1">
              <div style="margin-right: 12px">每日提现无审核上限</div>
              <el-input v-model="form.approveTypes[0].value" style="width: 200px"></el-input>
            </div>

            <div style="display: flex; align-items: center; flex: 1">
              <div style="margin-right: 12px">提现手续费</div>
              <el-input v-model="form.approveTypes[0].note" style="width: 200px"></el-input>
            </div>
          </div>
        </div>
      </div>


      <div v-if="form.quotationTypes">
        <div
          style="
            flex: 1;
            margin-right: 12px;
            background-color: white;
            padding: 12px;
            border-radius: 8px;
            margin-top: 12px;
          "
        >
          <div style="display: flex; align-items: center">
            <div
              style="
                height: 20px;
                width: 4px;
                margin-right: 12px;
                background: linear-gradient(#2456e0, #24ade0);
                border-radius: 4px;
              "
            ></div>
            <div style="font-size: 18px; font-weight: bold">报价打听</div>
          </div>
          <div style="margin-top: 12px; padding-left: 40px">
            <div style="display: flex; align-items: center; margin-top: 12px">
              <div style="margin-right: 12px">最低3人</div>
              <el-input
                style="flex: 1"
                v-model="form.quotationTypes[0].name"
              ></el-input>
            </div>
            <div style="display: flex; align-items: center; margin-top: 12px">
              <div style="margin-right: 12px">最低5人</div>
              <el-input
                style="flex: 1"
                v-model="form.quotationTypes[0].value"
              ></el-input>
            </div>
            <div style="display: flex; align-items: center; margin-top: 12px">
              <div style="margin-right: 12px">5人以上</div>
              <el-input
                style="flex: 1"
                v-model="form.quotationTypes[0].note"
              ></el-input>
            </div>
          </div>
        </div>
      </div>


    <div
        v-if="form.quotationStatusTypes"
        style="
          flex: 1;
          margin-right: 12px;
          background-color: white;
          padding: 12px;
          border-radius: 8px;
          margin-top: 12px;
        "
      >
        <div style="display: flex; align-items: center">
          <div
            style="
              height: 20px;
              width: 4px;
              margin-right: 12px;
              background: linear-gradient(#2456e0, #24ade0);
              border-radius: 4px;
            "
          ></div>
          <div style="font-size: 18px; font-weight: bold">报价状态设置</div>
        </div>
        <div style="margin-top: 12px; padding-left: 40px">
          <div
            style="display: flex; align-items: center; margin-top: 12px"
            v-for="(item1, idx) in form.quotationStatusTypes"
            :key="idx"
          >
            <div style="margin-right: 12px">人数</div>
            <el-input v-model="item1.name" style="width: 200px"></el-input>
            <div style="margin: 0 12px">人以下显示</div>
            <el-input style="flex: 1" v-model="item1.value"></el-input>
          </div>
        </div>
      </div>


<!-- 佣金折扣 -->
    <div
        v-if="form.kickbackTypes"
        style="
          flex: 1;
          margin-right: 12px;
          background-color: white;
          padding: 12px;
          border-radius: 8px;
          margin-top: 12px;
        "
      >
        <div style="display: flex; align-items: center">
          <div
            style="
              height: 20px;
              width: 4px;
              margin-right: 12px;
              background: linear-gradient(#2456e0, #24ade0);
              border-radius: 4px;
            "
          ></div>
          <div style="font-size: 18px; font-weight: bold">佣金折扣</div>
        </div>
        <div style="margin-top: 12px; padding-left: 40px">
          <div
            style="
              display: flex;
              align-items: center;
              margin-top: 12px;
              width: 70%;
            "
          >
            <div style="margin-right: 12px; width: 130px">会员等级</div>
            <div
              style="
                flex: 1;
                display: flex;
                align-items: center;
                justify-content: space-around;
              "
              :key="idx" v-for="(item, idx) in form.kickbackTypes[0].earnList" 
            >
              <el-input style="margin-right: 10px;" v-model="form.kickbackTypes[0].earnList[idx]"></el-input>
            </div>
          </div>

          <div
            style="
              display: flex;
              align-items: center;
              margin-top: 12px;
              width: 70%;
            "
          >
            <div style="margin-right: 12px; width: 130px">佣金折扣</div>
            <div
              style="
                flex: 1;
                display: flex;
                align-items: center;
                justify-content: space-around;
              "
            >
              <div
                style="
                  display: flex;
                  align-items: center;
                  margin-right: 10px;
                "
                :key="idx" v-for="(item, idx) in form.kickbackTypes[1].earnList" 
              >
                <el-input v-model="form.kickbackTypes[1].earnList[idx]"></el-input>
                <div style="font-size: 12px;">%</div>
              </div>
            </div>
          </div>

          <div
            style="
              display: flex;
              align-items: center;
              margin-top: 12px;
              width: 70%;
            "
          >
            <div style="margin-right: 12px; width: 130px">
              是否可以查看<br />师傅联系方式
            </div>
            <div
              style="
                flex: 1;
                display: flex;
                align-items: center;
                justify-content: space-around;
              "
            >
              <div style="display: flex; align-items: center" :key="idx" v-for="(item, idx) in form.kickbackTypes[2].earnList" >
                <el-checkbox
                  style="transform: scale(2)"
                  v-model="form.kickbackTypes[2].earnList[idx]"
                ></el-checkbox>
              </div>
            </div>
          </div>
        </div>
      </div>



       <div
        v-if="form.marginTypes"
        style="
          flex: 1;
          margin-right: 12px;
          background-color: white;
          padding: 12px;
          border-radius: 8px;
          margin-top: 12px;
        "
      >
        <div style="display: flex; align-items: center">
          <div
            style="
              height: 20px;
              width: 4px;
              margin-right: 12px;
              background: linear-gradient(#2456e0, #24ade0);
              border-radius: 4px;
            "
          ></div>
          <div style="font-size: 18px; font-weight: bold">保证金缴纳</div>
        </div>
        <div style="margin-top: 12px; padding-left: 40px">
          <div style="margin-top: 12px; width: 70%; display: flex">
            <div style="display: flex; align-items: center; margin-right: 12px">
              <div style="width: 100px;margin-right: 10px;" >普通保证金</div>
              <el-input v-model="form.marginTypes[0].name" style="margin-right: 10px;width: 200px"></el-input>
              <div style="width: 100px;margin-right: 10px;">中级保证金</div>
              <el-input v-model="form.marginTypes[0].value" style="margin-right: 10px;width: 200px"></el-input>
              <div style="width: 100px;margin-right: 10px;">高级保证金</div>
              <el-input v-model="form.marginTypes[0].note" style="width: 200px"></el-input>
            </div>
          </div>
        </div>
      </div>



        <div
        v-if="form.fileManagement"
        style="
          flex: 1;
          margin-right: 12px;
          background-color: white;
          padding: 12px;
          border-radius: 8px;
          margin-top: 12px;
        "
      >
        <div style="display: flex; align-items: center">
          <div
            style="
              height: 20px;
              width: 4px;
              margin-right: 12px;
              background: linear-gradient(#2456e0, #24ade0);
              border-radius: 4px;
            "
          ></div>
          <div style="font-size: 18px; font-weight: bold">文件管理</div>
        </div>
        <div style="margin-top: 12px; padding-left: 20px">
          <div style="margin-top: 12px; display: flex">
            <div style="display: flex; align-items: center; margin-right: 12px">
              <div style="font-size: 13px; margin-right: 12px">
                文件上传大小限制
              </div>
              <el-input style="width: 80px" v-model="form.fileManagement[0].name"></el-input>mb
            </div>

            <div style="display: flex; align-items: center; margin-right: 12px">
              <div style="font-size: 13px; margin-right: 12px">
                图片上传大小限制
              </div>
              <el-input style="width: 80px" v-model="form.fileManagement[0].value"></el-input>mb
            </div>

            <div style="display: flex; align-items: center; margin-right: 12px">
              <div style="font-size: 13px; margin-right: 12px">
                文件定时清理
              </div>
              <el-input style="width: 80px" v-model="form.fileManagement[0].note"></el-input>天
            </div>

            <div style="display: flex; align-items: center; margin-right: 12px">
              <div style="font-size: 13px; margin-right: 12px">
                图片定时清理
              </div>
              <el-input style="width: 80px" v-model="form.fileManagement[0].extendList[0]"></el-input>天
            </div>
          </div>
        </div>
      </div>



       <div
        v-if="form.pictureNote"
        style="
          flex: 1;
          margin-right: 12px;
          background-color: white;
          padding: 12px;
          border-radius: 8px;
          margin-top: 12px;
        "
      >
        <div style="display: flex; align-items: center">
          <div
            style="
              height: 20px;
              width: 4px;
              margin-right: 12px;
              background: linear-gradient(#2456e0, #24ade0);
              border-radius: 4px;
            "
          ></div>
          <div style="font-size: 18px; font-weight: bold">订单图片文字说明</div>
        </div>
        <div
          style="
            margin-top: 12px;
            padding-left: 20px;
            display: flex;
            align-items: center;
            width: 45%;
          "
        >
          <div style="margin-right: 12px">订单图片文字说明</div>
          <el-input
            style="flex: 1"
            v-model="form.pictureNote[0].name"
          ></el-input>
        </div>
        <div
          style="
            margin-top: 12px;
            padding-left: 20px;
            display: flex;
            align-items: center;
            width: 45%;
          "
        >
          <div style="margin-right: 12px">企业二维码说明</div>
          <el-input
            style="flex: 1"
            v-model="form.pictureNote[0].value"
          ></el-input>
        </div>
      </div>



    <div
      style="
        margin-top: 12px;
        padding-left: 20px;
        display: flex;
        align-items: center;
        width: 45%;
      "
    >
      <el-button type="primary" @click="onSubmit">立即保存</el-button>
    </div>
  </div>
</template>
<style scoped>
.el-tag + .el-tag {
  margin-left: 10px;
}
.button-new-tag {
  margin-left: 10px;
  height: 20px;
  line-height: 18px;
  padding-top: 0;
  padding-bottom: 0;
}
.input-new-tag {
  width: 90px;
  margin-left: 10px;
  vertical-align: bottom;
}
</style>
<script>
import {
  getYzSettingList,
  saveYzSetting,
} from "@/api/sysDict";
import { getListYzKind } from "@/api/yzKind";

export default {
  mounted() {
    // 获取信息
    getYzSettingList()
      .then((response) => {
        if (response.data.code === 200) {
          this.form = response.data.data[0] || {};
          // 设置时间约定方式
          this.initTimeTypes(response);
          // 设置技能证书str
          this.initSkillTypes();
          // 处理佣金折扣
          this.initEarnBack();
          // 文件管理
          this.initFileManagement();
        } else {
          this.$message({
            message: response.data.msg || '获取失败',
            type: 'error',
            showClose: true,
            duration: 3000,
          });
        }
      })
    this.getOrderAndSkillTypeList();
  },
  data() {
    return {
      form: [],
      workInputValue: "",
      types: [],
    };
  },
  methods: {
    // 初始化时间约定方式
    initTimeTypes(response) {
      this.form.timeLimitTypes = response.data.data[0].timeLimitTypes && response.data.data[0].timeLimitTypes.map(item => {
        const checkedList = item.extendList.map((ele, index) => {
          return ele === '是';
        })
        if (checkedList.length < 3) {
          checkedList.push(false)
        }
        return { ...item, checkedList }
      })
    },
    // 初始化技能证书
    initSkillTypes() {
      this.form.skillTypes = this.form.skillTypes.map(item => {
        if (item.extendList && Array.isArray(item.extendList)) {
          return { ...item, skillStr: this.getSkillCardStr(item.extendList) }
        }
        return { ...item, skillStr: '无' }
      })
    },
    // 初始化佣金折扣
    initEarnBack() {
      this.form.kickbackTypes = this.form.kickbackTypes.map((item, index) => {
        if (item.extendList && Array.isArray(item.extendList)) {
          if (index === 2) {
            const arr = item.extendList.map(ele => ele === '是');
            return { ...item, earnList: arr }
          }
          return { ...item, earnList: item.extendList }
        }
        if (index === 0) {
          return { ...item, earnList: ['普通', 'vip1', 'vip2', 'vip3'] }
        }
        return { ...item }
      })
      const emptyObj = { name: '', note: '', value: '', extendList: null }
      let list = [{ ...emptyObj, earnList: [0, 20, 60, 100] }, { ...emptyObj, earnList: [false, false, false, true] }]
      if (this.form.kickbackTypes.length < 2) {
        this.form.kickbackTypes = this.form.kickbackTypes.concat(list);
      }
      if (this.form.kickbackTypes.length < 3 && this.form.kickbackTypes.length > 1) {
        list = [{ ...emptyObj, earnList: [false, false, false, true] }]
        this.form.kickbackTypes = this.form.kickbackTypes.concat(list);
      }
    },
    initFileManagement() {
      const fileData = this.form.fileManagement[0];
      if (!(fileData.extendList && Array.isArray(fileData.extendList))) {
        this.form.fileManagement[0].extendList = [2000];
      }
    },
    workHandleClose(tag, userType) {
      const currUserType = userType === 'user' ? 'userRemarkTypes' : 'wokerRemarkTypes';
      const list = this.form[currUserType];
      list.forEach((element) => {
        const item1 = element.list;
        const index = item1.indexOf(tag);
        item1.forEach((item2) => {
          if (item2 == tag) {
            item1.splice(index, 1);
          }
        });
      });
    },

    workShowInput(type, userType) {
      const currUserType = userType === 'user' ? 'userRemarkTypes' : 'wokerRemarkTypes';
      if (type == "正面评价") {
        const updatedArr = this.form[currUserType].map((obj) => {
          if (obj.type === "正面评价") {
            return { type: obj.type, list: obj.list, workInputVisible: true };
          }
          return obj;
        });
        this.form[currUserType] = updatedArr;
      } else if (type == "负面评价") {
        const updatedArr = this.form[currUserType].map((obj) => {
          if (obj.type === "负面评价") {
            return { type: obj.type, list: obj.list, workInputVisible: true };
          }
          return obj;
        });
        this.form[currUserType] = updatedArr;
      }
    },

    workHandleInputConfirm(type, userType) {
      const currUserType = userType === 'user' ? 'userRemarkTypes' : 'wokerRemarkTypes';
      this.form[currUserType] = this.form[currUserType].map(item => {
        if (item.type === type) {
          item.list.push(item.inputValue);
          item.workInputVisible = false;
          return { ...item }
        }
        return { ...item }
      })
    },
    onAddTimeRow() {
      this.form.timeLimitTypes.push({ checkedList: [false, false, false], extendList: ['否', '否', '否'], name: '', value: '', note: ''})
    },
    onAddRoleRow() {
      this.form.roleTypes.push({ extendList: [], name: '', note: '', value: '' });
    },
    async getOrderAndSkillTypeList() {
      const { data } = await getListYzKind({});
      if (data.code === 200) {
        this.types = data.data || [];
      } else {
        this.$message({
          message: data.msg || '数据获取失败',
          type: 'error',
          showClose: true,
          duration: 3000,
        });
      }
    },
    getSkillCardStr(list) {
      if (list && Array.isArray(list)) {
        return list.join();
      }
      return ''
    },
    onAddSkillTypesRow() {
      this.form.skillTypes.push({ extendList: null, name: '', note: '', value: '' });
    },
    handleFormValue() {
      const formValue = { ...this.form };
      formValue.kickbackTypes = formValue.kickbackTypes.map(item => {
        const list = item.earnList.map(e => {
          if (typeof e === 'boolean' || e === 'false' || e === 'true') {
            return e || e === 'true' ? '是' : '否'
          }
          return e
        })
        const obj = { ...item, extendList: list }
        delete obj.earnList;
        return { ...obj }
      })
      formValue.skillTypes = formValue.skillTypes.map(item => {
        let obj = { ...item }
        if (item.skillStr === '无') {
          obj = { ...item }
        } else if (item.skillStr) {
          const list = item.skillStr.split(',');
          obj = { ...item, extendList: list }
        }
        delete obj.skillStr;
        return { ...obj }
      })
      formValue.timeLimitTypes = formValue.timeLimitTypes.map(item => {
        const list = item.checkedList.map(ele => ele ? '是' : '否');
        const obj = { ...item, extendList: list };
        delete obj.checkedList
        return obj;
      })
      formValue.userRemarkTypes = formValue.userRemarkTypes.map(item => {
        const obj = { ...item }
        delete obj.inputValue;
        delete obj.workInputVisible;
        return obj;
      })
      formValue.wokerRemarkTypes = formValue.wokerRemarkTypes.map(item => {
        const obj = { ...item }
        delete obj.inputValue;
        delete obj.workInputVisible;
        return obj;
      })
      return formValue;
    },
    onSubmit() {
      const formValue = this.handleFormValue();
      saveYzSetting(formValue)
        .then((response) => {
          if (response.data.code === 200) {
            this.$message({
              message: '保存成功',
              type: "success",
            });
          } else {
            this.$message({
              message: response.data.msg || '保存失败',
              type: 'error',
              showClose: true,
              duration: 3000,
            });
          }
        })
        .catch((response) => {
          console.log("error", response);
        });
    },
  },
};
</script>



